import * as React from 'react';
import classnames from 'classnames'
import { ResultCount, Pagination } from '..';
import NotFoundTemplate from '../NotFoundTemplate';
import './index.less'

export interface Props {
  className?: any;
  slot?: any;
  total?: number;
  current?: any;
  showContent?: boolean
  hideResultCount?: boolean
  hidePagination?: boolean
  onPageChange?: Function
}

export default class ListContainer extends React.Component<Props, any> {
  render() {
    const {
      className,
      slot,
      total,
      showContent = false,
      hideResultCount,
      hidePagination,
      current,
      onPageChange
    } = this.props;

    if (!showContent) {
      return (
        <div className="list-container">
          <NotFoundTemplate />
        </div>
      )
    }

    return (
      <div className={classnames("list-container", className)} >
        {!hideResultCount && <ResultCount count={total} slot={slot} />}
        {this.props.children}
        {!hidePagination && <Pagination onChange={onPageChange} current={current} total={total} />}
      </div>
    );
  }

}
